using System;
using Microsoft.WowAddonStudio.Lua.RuntimeService.ShellHost;
using Microsoft.WowAddonStudio.Lua.RuntimeService.WowBench;
using NUnit.Framework;

namespace Microsoft.WowAddonStudio.Lua.RuntimeService.Tests.Mocks
{
	/// <summary>
	/// 
	/// </summary>
	[Serializable]
	public class MockShellHost : BaseShellHost
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="MockShellHost"/> class.
		/// </summary>
		public MockShellHost()
		{
			shellName = "MockShell";
		}

		/// <summary>
		/// Executes a command on the <see cref="IShellHost"/>.
		/// </summary>
		/// <param name="command">Command to execute</param>
		public override void ExecuteCommand(string command)
		{
			Assert.AreEqual(ShellHostState.Running, ShellState);
		}

		/// <summary>
		/// This method is called when ShellTextBox creates the host instance for the first time.
		/// </summary>
		/// <param name="outputWriter">The <see cref="IOutputWriter"/> parameter.</param>
		/// <param name="startingDirectory">Preferred directory to start in.</param>
		/// <param name="executableName">The name of executable to load.</param>
		/// <param name="argument">The argument for executable.</param>
		/// <returns></returns>
		/// <remarks>This method will only be called once at the beginning.</remarks>
		public override bool LaunchShellProcess(IOutputWriter outputWriter, string startingDirectory, string executableName,
		                                        string argument)
		{
			Console.WriteLine("MockShellHost:LaunchShellProcess -> {0} {1}", executableName, argument);
			Assert.IsNotNull(outputWriter);
			ShellState = ShellHostState.Running;
			return true;
		}

		/// <summary>
		/// This method is called when ShellTextBox creates the host instance for the first time.
		/// </summary>
		/// <param name="outputWriter">The <see cref="IOutputWriter"/> parameter.</param>
		/// <param name="startingDirectory">Preferred directory to start in.</param>
		/// <param name="executableName">The name of executable to load.</param>
		/// <returns></returns>
		/// <remarks>This method will only be called once at the beginning.</remarks>
		public override bool LaunchShellProcess(IOutputWriter outputWriter, string startingDirectory, string executableName)
		{
			Console.WriteLine("MockShellHost:LaunchShellProcess -> {0}", executableName);
			Assert.IsNotNull(outputWriter);
			ShellState = ShellHostState.Running;
			return true;
		}

		/// <summary>
		/// This method is called when ShellTextBox creates the host instance for the first time.
		/// </summary>
		/// <param name="outputWriter">The <see cref="IOutputWriter"/> parameter.</param>
		/// <param name="startingDirectory">Preferred directory to start in.</param>
		/// <returns></returns>
		/// <remarks>This method will only be called once at the beginning.</remarks>
		public override bool LaunchShellProcess(IOutputWriter outputWriter, string startingDirectory)
		{
			Console.WriteLine("MockShellHost:LaunchShellProcess -> default");
			Assert.IsNotNull(outputWriter);
			ShellState = ShellHostState.Running;
			return true;
		}
	}
}